package tmt.usercenter.web.vo.user;

import com.tmt.spring.validation.RequiredField;
import lombok.Getter;
import lombok.Setter;
import tmt.usercenter.web.domain.TmtUser;
import tmt.usercenter.web.domain.enums.IdCardType;

import java.io.Serializable;
import java.util.Date;

@Getter
@Setter
public class UserInfoVo implements Serializable {

	public static final String NICKNAME = "nickname";
	public static final String REAL_NAME = "realName";
	public static final String CARD_TYPE = "cardType";
	public static final String ID_CARD_NUM = "idCardNum";
	public static final String BIRTHDAY = "birthday";

	private String avatar;

	private String username;

	@RequiredField(label = "用户昵称", order = 4)
	private String nickname;

	@RequiredField(label = "真实姓名", order = 5)
	private String realName;

	@RequiredField(label = "证件类型", order = 6)
	private IdCardType cardType = IdCardType.ID_CARD_2;

	@RequiredField(label = "身份证号", order = 7, methodName = "*")
	private String idCardNum;

	@RequiredField(label = "出生日期", order = 8, methodParam = {"idCardNum"})
	private Date birthday;

	public static UserInfoVo from(TmtUser user) {
		UserInfoVo vo = new UserInfoVo();

		vo.setAvatar(user.getAvatar());
		vo.setUsername(user.getUsername());
		vo.setNickname(user.getNickname());
		vo.setRealName(user.getRealName());
		vo.setCardType(user.getCardType());
		vo.setIdCardNum(user.getIdCardNum());
		vo.setBirthday(user.getBirthday());

		return vo;
	}

}
